package com.xxx.controller;

import com.xxx.service.KafkaProducerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class KafkaController {

    @Autowired
    private KafkaProducerService kafkaProducerService;

    /**
     * 测试发送消息
     * http://localhost:8080/send?key=&message=hello,world
     */
    @GetMapping("/send")
    public String sendMessage(String key, String message) {
        kafkaProducerService.sendMessage("test", key, message);
        return "Message sent: " + message;
    }
}
